package org.locker.service;


import org.locker.common.core.exception.ServiceException;
import org.locker.common.core.utils.SpringUtils;
import org.locker.domain.vo.LoginWxVo;

/**
 * 授权策略
 *
 * @author Michelle.Chung
 */
public interface IAuthStrategy {

    String BASE_NAME = "AuthStrategy";
    String WX_GRANT_TYPE = "wx";

    /**
     * 登录
     */
    static LoginWxVo login(String openId) {

        // 授权类型和客户端id
        String grantType = WX_GRANT_TYPE;
        String beanName = grantType + BASE_NAME;
        if (!SpringUtils.containsBean(beanName)) {
            throw new ServiceException("授权类型不正确!");
        }
        IAuthStrategy instance = SpringUtils.getBean(beanName);
        return instance.loginByOpenId(openId);
    }

    LoginWxVo loginByOpenId(String openId);

}
